import time


#函数功能：写日志文件！
#形参serviceName:业务名称。String。举例："loginService"
#形参cesi_data：Dict类型。某条测试数据。举例:{"key":"K001","zanhao":"张三","pwd":"123456"}
#形参result:Bool。该条测试用例的执行结果。True:成功。False：失败
def wirteLog(ServiceName,cesi_data,result):
    aa = time.strftime("%Y-%m-%d %H:%M:%S")#"2023-09-13 15:00"
    temp1=aa[:10]
    temp2=temp1.replace("-","")
    fileName=f"log/{ServiceName}_{temp2}.log"
    fp=open(fileName,"a",encoding="utf-8")
    ret = ""
    for k, v in cesi_data.items():
        temp1 = f"{k}:{v},"
        ret += temp1

    ret1=""
    if result:
        ret1="成功"
    else:
        ret1="失败"

    #"2023-09-13 11:42:05 执行用例：K00,张三李四。执行结果：成功"
    fp.write(f"{aa} 执行用例:{ret} 执行结果:{ret1}!\n")
    fp.close()